package com.bcxj.serviceorder.controller;

import com.bcxj.internalcommon.dto.OrderRequest;
import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.serviceorder.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

/**
 * ClassName: OrderController
 * Package: com.bcxj.serviceorder.controller
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/11/9 15:17
 * @Version 1.0
 * @Since 1.0
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;


    /**
     * 添加订单
     * @param orderRequest
     * @return
     */
    @PostMapping("/add")
    public ResponseResult add(@RequestBody OrderRequest orderRequest) {
        log.info("orderRequest:{}", orderRequest);
        return orderInfoService.add(orderRequest);
    }


    /**
     * 司机去接乘客
     * @param orderRequest
     * @return
     */
    @PostMapping("to-pick-up-passenger")
    public ResponseResult toPickUpPassenger(@RequestBody OrderRequest orderRequest) {
        return orderInfoService.toPickUpPassenger(orderRequest);
    }


    /**
     * 司机到达出发点
     * @param orderRequest
     * @return
     */
    @PostMapping("arrived-departure")
    public ResponseResult arrivedDeparture(@RequestBody OrderRequest orderRequest) {
        return orderInfoService.arrivedDeparture(orderRequest);
    }


    /**
     * 司机接到乘客
     * @param orderRequest
     * @return
     */
    @PostMapping("pick-up-passenger")
    public ResponseResult pickUpPassenger(@RequestBody OrderRequest orderRequest) {
        return orderInfoService.pickUpPassenger(orderRequest);
    }

    /**
     * 乘客到达目的地/乘客下车
     * @param orderRequest
     * @return
     */
    @PostMapping("/order-getoff")
    public ResponseResult orderGetoff(@RequestBody OrderRequest orderRequest) {
        return orderInfoService.orderGetoff(orderRequest);
    }


    /**
     * 乘客支付订单/订单完成
     * @param orderRequest
     * @return
     */
    @PostMapping("/pay")
    public ResponseResult pay(@RequestBody OrderRequest orderRequest) {
        return orderInfoService.pay(orderRequest);
    }

    /**
     * 订单取消
     * @param orderId
     * @param identity
     * @return
     */
    @PostMapping("/cancel")
    public ResponseResult cancel(@RequestParam String orderId, @RequestParam String identity) {
        return orderInfoService.cancel(orderId, identity);
    }

    /**
     * 司机发起收款
     * @param orderRequest
     * @return
     */
    @PostMapping("/push-pay-info")
    public ResponseResult pushPayInfo(@RequestBody OrderRequest orderRequest) {
        return orderInfoService.pushPayInfo(orderRequest);
    }

}
